<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Scuola Media E. d'Arborea - Lamarmora </title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Il sito della scuola secondaria superiore di Iglesias, in Sardegna" />
<meta name="keywords" content="scuola, iglesias, didattica, insegnamento, docenti" />
<link rel="stylesheet" href="andreas08.css" type="text/css" media="screen,projection" />
<script type="text/javascript" src="/js/prototype.js"></script> 
<script type="text/javascript" src="/js/scriptaculous.js"></script>
<script type="text/javascript" src="/js/page.js"></script>
<script type="text/javascript">
function registra(){
	var patt = /[^a-zA-Z0-9]/;
	if(trim(document.forms[0].new_pwd.value) == ""){
		alert("Password non valida.");
		return false;
	}
	else if(document.forms[0].new_pwd.value.match(patt)){
		alert("Password non valida: sono ammessi solo lettere e numeri");
		return false;
	}
	if(trim(document.forms[0].new_pwd.value) != trim(document.forms[0].cfm_pwd.value)){
		alert("Le password inserite sono differenti. Ricontrolla.");
		return false;
	}
	p = hex_md5(document.forms[0].new_pwd.value);
	// fake password
	document.forms[0].new_pwd.value = "calatafimi";
	var req = new Ajax.Request('/shared/new_pwd.php',
			  {
			    	method:'post',
			    	parameters: {new_pwd: p, table: 'utenti', campo: 'uid', p2: document.forms[0].new_pwd.value, from: ''},
			    	onSuccess: function(transport){
			      		var response = transport.responseText || "no response text";
			      		//alert(response);
			      		var dati = response.split("|");
			      		alert("Password modificata correttamente");
		            	if(dati[1] == "redirect"){
							window.location = "index.php";
		            	}
			    	},
			    	onFailure: function(){ alert("Si e' verificato un errore...") }
			  });
}

function pwd_ok(){
	if(request.readyState == 4){
        if(request.status == 200){
            alert(request.responseText);
            //return;
            if(request.responseText != "ko"){
            	var dati = request.responseText.split(";");
                alert("Password modificata correttamente");
            	if(dati[1] == "redirect"){
					window.location = "index.php";
            	}
           	}
           	else{
                alert("Password non modificata: "+request.responseText);
            	window.close();
                return;
           	}
        }
        else{
            alert("Si e' verificato un problema di comunicazione col server");
        }
    }
}
</script>
</head>

<body>
<div id="container" >

<div id="header">
<h1>Scuola Media E. d'Arborea - Lamarmora</h1>
<h2>area riservata ai docenti</h2>
</div>

<?php include "navigation.php" ?>

<div id="content">
<h2 style="text-align: center">Modifica password</h2>
<form id="my_form" method="post" action="/shared/new_pwd.php" style="border: 1px solid #467aa7; margin-top: 30px; text-align: left; width: 460px; margin-left: auto; margin-right: auto; background-color: #F8F8F8">
<table style="width: 400px; margin-left: auto; margin-right: auto; margin-top: 30px; margin-bottom: 20px">
<tr>
<td style="width: 60%">Nuova password</td>
<td style="width: 40%"><input type="password" name="new_pwd" style="width: 250px; font-size: 11px; border: 1px solid gray" /></td> 
</tr>
<tr>
<td style="width: 60%">Conferma password</td>
<td style="width: 40%"><input type="password" name="cfm_pwd" style="width: 250px; font-size: 11px; border: 1px solid gray" /></td> 
</tr>
<tr>
<td colspan="2">&nbsp;</td> 
</tr>
<tr>
<td colspan="2" style="text-align: right; margin-right: 50px"><input type="button" onclick="registra()" value="Registra" style="margin-right: 0px; border: 1px solid #c0c0c0; font-size: 11px; padding-top: 2px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px" /></td> 
</tr>
</table>
</form>
</div>
<div id="subcontent">
<?php include 'smallbox.php'; ?>
<?php include "profile_menu.php" ?>
</div>
<?php include "footer.php" ?>
</div>
</body>
</html>